﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using WCFContracts;

namespace WCFClient
{
    public static class UsingService2
    {
        public static void Exucte()
        {
            ChannelFactory<ICalculator> factory = new ChannelFactory<ICalculator>("calculatorservice");
            ICalculator proxy = factory.CreateChannel();
            using (proxy as IDisposable)
            {
                Console.WriteLine("x + y = {2} when x = {0} and y = {1}", 1, 2, proxy.Add(1, 2));
                Console.WriteLine("x - y = {2} when x = {0} and y = {1}", 1, 2, proxy.Subtract(1, 2));
                Console.WriteLine("x * y = {2} when x = {0} and y = {1}", 1, 2, proxy.Multiply(1, 2));
                Console.WriteLine("x / y = {2} when x = {0} and y = {1}", 1, 2, proxy.Divide(1, 2));
                Console.WriteLine("x  = {1} when x = {0}",  2, proxy.Add( 2));
            }
        }
    }
}
